home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 407 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  41 lines

  1. Newsgroups: comp.lang.c++
  2. Path: usenet.eel.ufl.edu!warwick!bsmail!talisker!nathan
  3. From: nathan@pact.srf.ac.uk (Nathan Sidwell)
  4. Subject: Re: Poor floating point code in BC++
  5. Message-ID: <DKnMHr.IqA@uns.bris.ac.uk>
  6. Sender: usenet@uns.bris.ac.uk (Usenet news owner)
  7. Nntp-Posting-Host: talisker.pact.srf.ac.uk
  8. Organization: Inmos
  9. X-Newsreader: TIN [version 1.2 PL2]
  10. References: <4ca5bk$ff@fountain.mindlink.net> <4cc09j$6fm$1@mhafc.production.compuserve.com>
  11. Date: Thu, 4 Jan 1996 11:27:27 GMT
  12.  
  13. Dave Hand (70621.3624@CompuServe.COM) wrote:
  14. : >     That there is a function call is no surprise.  X is 
  15. : float and n
  16. : > is int.  A conversion is necessary.  From the name, that looks 
  17. : like what the routine called does.
  18.  
  19. : No, all that is necessary is the fistp instruction. The 
  20. : coprocessor has a special instruction to convert a float or 
  21. : double to an int. 
  22.  
  23. Not necessarily, as I pointed out in a previous post, a fistp is insufficent
  24. if the rounding mode is unknown, or known not to be round to zero.
  25. Conversion of a float to an int must produce the value closer to zero
  26. (because the standard says so).
  27. Such a restriction is not required for other floating point arithmetic,
  28. because the C standard does not say anything about rounding.
  29.  
  30. Many C systems permit the rounding mode to be set by a call, it appears
  31. that borland C is one such system.
  32.  
  33. nathan
  34.  
  35. --
  36. Nathan Sidwell                         Holder of the Xmris home page
  37. Chameleon Architecture Group at SGS-Thomson, formerly Inmos
  38. http://www.pact.srf.ac.uk/~nathan/                  Tel 0117 9707182
  39. nathan@inmos.co.uk or nathan@bristol.st.com or nathan@pact.srf.ac.uk
  40. Having problems?     try http://www.pact.srf.ac.uk/~nathan/problems/
  41.